home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / aptitude < prev    next >
Encoding:
Text File  |  2010-11-16  |  3.1 KB  |  99 lines

  1. # Debian aptitude(1) completion
  2.  
  3. have aptitude && {
  4. have grep-status && {
  5. _comp_dpkg_hold_packages()
  6. {
  7.     grep-status -P -e "^$1" -a -FStatus 'hold' -n -s Package
  8. }
  9. } || {
  10. _comp_dpkg_hold_packages()
  11. {
  12.     command grep -B 2 'hold' /var/lib/dpkg/status | \
  13.         command grep "Package: $1" | cut -d\  -f2
  14. }
  15. }
  16.  
  17. _aptitude()
  18. {
  19.     local cur dashoptions prev special i
  20.  
  21.     COMPREPLY=()
  22.     _get_comp_words_by_ref cur prev
  23.  
  24.     dashoptions='-S -u -i -h --help --version -s --simulate -d \
  25.         --download-only -P --prompt -y --assume-yes -F \
  26.         --display-format -O --sort -w --width -f -r -g \
  27.         --with-recommends -R -G --without-recommends -t \
  28.         --target-release -V --show-versions -D --show-deps\
  29.         -Z -v --verbose --purge-unused --schedule-only'
  30.  
  31.     for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
  32.         if [[ ${COMP_WORDS[i]} == @(@(|re)install|@(|un)hold|@(|un)markauto|@(dist|full)-upgrade|download|show|forbid-version|purge|remove|changelog|why@(|-not)|keep@(|-all)|build-dep|@(add|remove)-user-tag) ]]; then
  33.         special=${COMP_WORDS[i]}
  34.         fi
  35.         #exclude some mutually exclusive options
  36.         [[ ${COMP_WORDS[i]} == '-u' ]] && dashoptions=${dashoptions/-i}
  37.         [[ ${COMP_WORDS[i]} == '-i' ]] && dashoptions=${dashoptions/-u}
  38.     done
  39.  
  40.     if [[ -n "$special" ]]; then
  41.        case $special in
  42.            install|hold|markauto|unmarkauto|dist-upgrade|full-upgrade| \
  43.            download|show|changelog|why|why-not|build-dep|add-user-tag| \
  44.            remove-user-tag)
  45.                COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
  46.                return 0
  47.                ;;
  48.            purge|remove|reinstall|forbid-version)
  49.                COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) )
  50.                return 0
  51.                ;;
  52.            unhold)
  53.                COMPREPLY=( $( _comp_dpkg_hold_packages "$cur" ) )
  54.                return 0
  55.                ;;
  56.        esac
  57.     fi
  58.  
  59.     case $prev in
  60.         # don't complete anything if these options are found
  61.         autoclean|clean|forget-new|search|safe-upgrade|upgrade|update|keep-all)
  62.             return 0
  63.             ;;
  64.         -S)
  65.             _filedir
  66.             return 0
  67.             ;;
  68.         -t|--target-release|--default-release)
  69.             COMPREPLY=( $( apt-cache policy | \
  70.                 command grep "release.o=Debian,a=$cur" | \
  71.                 sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null ) )
  72.             return 0
  73.             ;;
  74.     esac
  75.  
  76.     if [[ "$cur" == -* ]]; then
  77.         COMPREPLY=( $( compgen -W "$dashoptions" -- "$cur" ) )
  78.     else
  79.         COMPREPLY=( $( compgen -W 'update upgrade safe-upgrade forget-new \
  80.             clean autoclean install reinstall remove \
  81.             hold unhold purge markauto unmarkauto why why-not \
  82.             dist-upgrade full-upgrade download search show \
  83.             forbid-version changelog keep-all build-dep \
  84.             add-user-tag remove-user-tag' -- "$cur" ) )
  85.     fi
  86.  
  87.     return 0
  88. }
  89. complete -F _aptitude -o default aptitude
  90. }
  91.  
  92. # Local variables:
  93. # mode: shell-script
  94. # sh-basic-offset: 4
  95. # sh-indent-comment: t
  96. # indent-tabs-mode: nil
  97. # End:
  98. # ex: ts=4 sw=4 et filetype=sh
  99.